package com.yang.travel.service.impl;

import com.yang.travel.utils.RedisUtlis;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import javax.mail.MessagingException;
import javax.mail.internet.MimeMessage;
@Service
public class MailService {
    @Autowired
    JavaMailSenderImpl mailSender;
    @Async
    public void sendMail(String to)throws MessagingException{
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        mailMessage.setSubject("密码更改通知");
        mailMessage.setText("您的密码已修改，下次登录时需要使用新的密码登录，如不是本人操作请及时找回自己的用户密码！");
        mailMessage.setTo(to);
        mailMessage.setFrom("yyq-11@139.com");
        mailSender.send(mailMessage);
//        long subs = utlis.incr("subs", 1);
//        subs++;
//        String keys="sub:"+subs;
//        utlis.hset("post:subs",keys,to);
    }
//    public void changeProfileMail(String to){
//        SimpleMailMessage mailMessage = new SimpleMailMessage();
//        mailMessage.setSubject("用户信息更改通知");
//        mailMessage.setText("尊敬的用户，您的账号信息已更改，如不是本人操作，请及时找回密码重新更改自己的账户号信息！");
//        mailMessage.setTo(to);
//        mailMessage.setFrom("yyq-11@139.com");
//        mailSender.send(mailMessage);
//    }
}
